package bb.lanxing.activity.base;

import android.os.Bundle;
import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;

import bb.lanxing.activity.interfaces.IBaseCommon;
import bb.lanxing.activity.interfaces.IBaseDialog;
import bb.lanxing.activity.interfaces.IBaseLoadData;
import bb.lanxing.activity.interfaces.IBaseView;
import bb.lanxing.view.dialog.CustomProgressDialog;


public abstract class BaseCommonActivity extends AppCompatActivity implements IBaseDialog, IBaseCommon, IBaseView, IBaseLoadData {
    private final IBaseDialog mBaseDialog = new CustomProgressDialog(this);
    private final IBaseCommon mIBaseCommon = new BaseCommonHelper(this);

    public BaseCommonActivity() {

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void goTargetActivity(Class<?> cls) {
        mIBaseCommon.goTargetActivity(cls);
    }

    @Override
    public void goTargetActivity(Class<?> cls, Bundle bundle) {
        mIBaseCommon.goTargetActivity(cls, bundle);
    }

    @Override
    public void showLoading() {
        mBaseDialog.showLoading();
    }

    @Override
    public void dismissLoading() {
        mBaseDialog.dismissLoading();
    }

}
